﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BruteForce.Animation
{
    public class LinearFrameAnimationTransition : Transition
    {
        public double TextureSwitchDuration;
        public List<Texture2D> Textures;

        public LinearFrameAnimationTransition(double duration, List<Texture2D> frames, double frameDuration)
            : base(duration)
        {
            Textures = frames;
            TextureSwitchDuration = frameDuration;
        }

        public Texture2D CurrentTexture
        {
            get
            {
                var cframe = (int) (Value/TextureSwitchDuration);
                return Textures[cframe%Textures.Count];
            }
        }

        public override void Interpolate(GameTime time)
        {
            double t = Time/Duration;
            Value = t;
        }
    }
}